/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ortustve.onlinescrapper.themoviedb;

import java.io.File;
import java.io.Serializable;

/**
 *
 * @author jphipps
 */
public class CastItem extends ortustve.ortusvars implements Serializable {

    String name;
    String job;
    String character;
    String url;
    String thumb;

    public CastItem(String name, String job, String character, String url, String thumb) {
        this.name = name;
        this.job = job;
        this.character = character;
        this.url = url;
        this.thumb = thumb;
        ortustve.api.DebugLog(TRACE2, " CastItem: " + name);
    }

    public String GetName() {
        return name;
    }
    
    public String GetJob() {
        return job;
    }

    public String GetCharacter() {
        return character;
    }
    public String GetUrl() {
        return url;
    }

    public String GetThumb() {
        return thumb;
    }

    public boolean HasThumb() {
        if ( thumb.isEmpty())
            return false;
        else
            return true;
    }
    
    public void getImage() {
        String downloaddir = ortustve.api.GetFanartFolder() + java.io.File.separator + "Cast" + java.io.File.separator + name;
        String filename = thumb.substring(thumb.lastIndexOf("/") + 1);

        File af = new File(downloaddir + java.io.File.separator + filename);
        if ( af.exists()) {
            ortustve.api.DebugLog(TRACE, "Cast: " + name + " already exists, skipping");
            return;
        }

        ortustve.api.DebugLog(TRACE2, " getImage: " + filename + " dir: " + downloaddir);
        	ortustve.onlinescrapper.tools.urldownload.fileDownload(thumb, downloaddir );

        return;
    }
}
